<html>
<head><meta charset="utf-8"><title>types in ffi · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/types.20in.20ffi.html">types in ffi</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="200901627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/types%20in%20ffi/near/200901627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Poliorcetics <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/types.20in.20ffi.html#200901627">(Jun 15 2020 at 15:07)</a>:</h4>
<p>Hello !<br>
in a <code>.h</code> file I have types that are defined as</p>
<div class="codehilite"><pre><span></span><code><span class="k">typedef</span> <span class="k">struct</span> <span class="n">_DDCFile</span> <span class="n">DDCFile</span><span class="p">;</span>
<span class="k">typedef</span> <span class="k">struct</span> <span class="n">_DDCChannelGroup</span> <span class="n">DDCChannelGroup</span><span class="p">;</span>
<span class="k">typedef</span> <span class="k">struct</span> <span class="n">_DDCChannel</span> <span class="n">DDCChannel</span><span class="p">;</span>

<span class="k">typedef</span> <span class="n">DDCFile</span><span class="o">*</span> <span class="n">DDCFileHandle</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">DDCChannelGroup</span><span class="o">*</span> <span class="n">DDCChannelGroupHandle</span><span class="p">;</span>
<span class="k">typedef</span> <span class="n">DDCChannel</span><span class="o">*</span> <span class="n">DDCChannelHandle</span><span class="p">;</span>
</code></pre></div>


<p>I don't have access to their original definition, how can I represent them in an <code>extern "C" { fn close(f: DDCFileHandle) }</code> ?</p>
<p>From what I'm reading in the reference, I cannot write a type inside an extern bloc.</p>



<a name="200907576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/types%20in%20ffi/near/200907576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/types.20in.20ffi.html#200907576">(Jun 15 2020 at 15:44)</a>:</h4>
<p><a href="https://stackoverflow.com/q/38315383/155423">What's the Rust idiom to define a field pointing to a C opaque pointer?</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>